<template>
	<div class="app-container">
		<!-- 基本设置 -->
		<div class="filter-container tw-filter">
			<el-tabs type="card">
				<!-- 基本设置 -->
				<!-- <el-tab-pane label="基本设置">
					<el-form ref="dataForm" :model="form" label-position="center" label-width="100px"
						style="width: 500px; margin-left:50px;">
						<el-form-item label="分销返现比例" prop="invite_commis_rate">
							<el-input v-model="form.invite_commis_rate" placeholder="请输入分销返现比例" style="width:400px;"
								class="filter-item tw-filter-input" />
							<p style="margin:0;">{invite_commis_rate}分销上级返现比例(%),范围0-100</p>
						</el-form-item>
					</el-form>
					<el-button style="margin-left: 250px;" v-waves class="filter-item tw-filter-button" type="primary"
						@click="updateData()">保存</el-button>
				</el-tab-pane> -->

				<!-- 用户积分规则 -->
				<el-tab-pane label="用户积分规则">
					<el-form ref="dataForm" :model="form" label-position="center" label-width="200px"
						style="width: 600px; margin-left:50px;">
						<el-form-item label="是否开启用户积分" prop="points_is_use">
							<el-radio-group v-model="form.points_is_use">
								<el-radio :label="1">是</el-radio>
								<el-radio :label="0">否</el-radio>
							</el-radio-group>
						</el-form-item>
						<el-form-item label="用户注册" prop="points_reg">
							<el-input v-model="form.points_reg" style="width:400px;"
								class="filter-item tw-filter-input" />
							<p style="margin:0;">送多少积分,整数</p>
						</el-form-item>
						<el-form-item label="每天登录" prop="points_login">
							<el-input v-model="form.points_login" style="width:400px;"
								class="filter-item tw-filter-input" />
							<p style="margin:0;">送多少积分,整数</p>
						</el-form-item>
						<!-- <el-form-item label="每天签到" prop="points_signed">
							<el-input v-model="form.points_signed" style="width:400px;"
								class="filter-item tw-filter-input" />
							<p style="margin:0;">送多少积分,整数</p>
						</el-form-item> -->
						<el-form-item label="邀请注册" prop="points_invite">
							<el-input v-model="form.points_invite" style="width:400px;"
								class="filter-item tw-filter-input" />
							<p style="margin:0;">送多少积分,整数</p>
						</el-form-item>
						<el-form-item label="评论" prop="points_comments">
							<el-input v-model="form.points_comments" style="width:400px;"
								class="filter-item tw-filter-input" />
							<p style="margin:0;">送多少积分,整数</p>
						</el-form-item>
            <el-form-item label="预约挂号" prop="points_other_1">
            	<el-input v-model="form.points_other_1" style="width:400px;"
            		class="filter-item tw-filter-input" />
            	<p style="margin:0;">送多少积分,整数</p>
            </el-form-item>
            <el-form-item label="在线问诊" prop="points_other_2">
            	<el-input v-model="form.points_other_2" style="width:400px;"
            		class="filter-item tw-filter-input" />
            	<p style="margin:0;">送多少积分,整数</p>
            </el-form-item>
						<el-form-item label="消费额与赠送积分比例" prop="points_order_rate">
							<el-input v-model="form.points_order_rate" style="width:400px;"
								class="filter-item tw-filter-input" />
							<p style="margin:0;">该值为大于0的整数,例:设置为10,表明满10元赠送1积分</p>
						</el-form-item>
						<el-form-item label="每订单最多赠送积分" prop="points_order_max">
							<el-input v-model="form.points_order_max" style="width:400px;"
								class="filter-item tw-filter-input" />
							<p style="margin:0;">该值为大于等于0的整数,填写为0表示不限制最多积分,例:设置为100,表明每订单赠送积分最多为100积分</p>
						</el-form-item>
					</el-form>
					<el-button style="margin-left: 250px;" v-waves class="filter-item tw-filter-button" type="primary"
						@click="updateData()">保存</el-button>
				</el-tab-pane>

				<!-- 用户经验值规则 -->
				<!-- <el-tab-pane label="用户经验值规则">
					<el-form ref="dataForm" :model="form" label-position="center" label-width="200px"
						style="width: 600px; margin-left:50px;">
						<el-form-item label="每天登录" prop="exppoints_login">
							<el-input v-model="form.exppoints_login" placeholder="请输入旧密码" style="width:400px;"
								class="filter-item tw-filter-input" />
							<p style="margin:0;">送多少经验值,整数</p>
						</el-form-item>
						<el-form-item label="每天签到" prop="exppoints_signed">
							<el-input v-model="form.exppoints_signed" placeholder="请输入旧密码" style="width:400px;"
								class="filter-item tw-filter-input" />
							<p style="margin:0;">送多少经验值,整数</p>
						</el-form-item>
						<el-form-item label="评论" prop="exppoints_comments">
							<el-input v-model="form.exppoints_comments" placeholder="请输入旧密码" style="width:400px;"
								class="filter-item tw-filter-input" />
							<p style="margin:0;">送多少经验值,整数</p>
						</el-form-item>
						<el-form-item label="消费额与赠送经验值比例" prop="exppoints_order_rate">
							<el-input v-model="form.exppoints_order_rate" placeholder="请输入旧密码" style="width:400px;"
								class="filter-item tw-filter-input" />
							<p style="margin:0;">该值为大于0的整数,例:设置为10,表明满10元赠送1经验值</p>
						</el-form-item>
						<el-form-item label="每订单最多赠送经验值" prop="exppoints_order_max">
							<el-input v-model="form.exppoints_order_max" placeholder="请输入旧密码" style="width:400px;"
								class="filter-item tw-filter-input" />
							<p style="margin:0;">该值为大于等于0的整数,填写为0表示不限制最多经验值,例:设置为100,表明每订单赠送经验值最多为100积分</p>
						</el-form-item>
					</el-form>
					<el-button style="margin-left: 250px;" v-waves class="filter-item tw-filter-button" type="primary"
						@click="updateData()">保存</el-button>
				</el-tab-pane> -->
			</el-tabs>
		</div>
		<!-- <div slot="footer">
      <el-button style="margin-left: 150px;" v-waves class="filter-item tw-filter-button" type="primary" @click="updateData()">保存</el-button>
    </div> -->

	</div>
</template>

<script>
	import waves from '@/directive/waves' // waves directive

	export default {
		directives: {
			waves
		},
		data() {
			return {
        apiPath: 'project.setting',
				// 表单数据
				form: {
					invite_commis_rate: '', //分销返现比例，范围：0-100
					points_is_use: 1,
					points_reg: 0,
					points_login: 0,
					points_signed: 0,
					points_invite: 0,
					points_comments: 0,
					points_order_rate: 0,
					points_order_max: 0,
          points_other_1: 0,
          points_other_2: 0,
					exppoints_login: 0,
					exppoints_signed: 0,
					exppoints_comments: 0,
					exppoints_order_rate: 0,
					exppoints_order_max: 0,
				},
			}
		},
		created() {
			// 获取详情
			this.$api.getDetail({}, this.apiPath).then(response => {
			  //数据处理
			  for(let key in this.form){
			    if(response.detail.hasOwnProperty(key)){
			      this.form[key] = response.detail[key]
			    }
			  }
			})
		},
		methods: {
      // 保存数据
      updateData() {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            this.$api.edit(this.form, this.apiPath).then(response => {
              this.$message({
                message: '保存成功',
                type: 'success'
              })
            })
          }
        })
      }
		}
	}
</script>
